<%@ Control Language="C#" %>
<%@ Import Namespace="IRL.Utilities" %>
<script runat="server">
    private bool __IsPostBack;
    protected void Page_Load(object sender, EventArgs e)
    {
        // Put user code to initialize the page here
        //string scriptStr = "__doPostBack(\'" + ClientID + "$imgSearch"  + @"', '');}";
        string scriptStr = "\n<" + "!--\n\t" +
                        "function SideBarSearch() {\n\t\t" +
                            "var theform;\n\t\t" +
                            "if (window.navigator.appName.toLowerCase().indexOf(\"netscape\") > -1) {\n\t\t\t" +
                                "theform = document.forms[\""+ Parent.ClientID +"\"];\n\t\t" +
                            "} else {\n\t\t\t" +
                                "theform = document."+ Parent.ClientID +";\n\t\t" +
                            "}\n\t\t" +
                            "theform."+ ClientID +"_SideBarPostBack.value='true';\n\t\t" +
                            "theform.submit();\n\t" +
                        "}\n" + 
                    "-->\n";
        txtSearch.Attributes.Add("onkeypress", "if(event.keyCode==13){SideBarSearch();};");
        //imgSearch.Attributes.Add("onclick", "SideBarSearch();");

        Page.RegisterClientScriptBlock("SideBarSearch", "<script language=\"javascript\">" + scriptStr + "</"+"script>");
    }

    public bool IsPostBack
    {
        get { return __IsPostBack; }    
    }
    
    
    public string client
    {
        get { return cboClient.SelectedValue; }
        set { cboClient.SelectedValue = value; }
    }
    public string search
    {
        get { return txtSearch.Text; }
        set { txtSearch.Text = value; }
    }        

    public void loadData()
    {
        if (!Page.IsPostBack)
        {
            ListItem li = new ListItem("*-ALL-*", "0");

            List.fillList(cboClient, "SELECT [Company_ID], [Company_Name] FROM [vw_Clients] ORDER BY [Company_Name];");
            cboClient.Items.Insert(0, li);
            // load reminder count            
            refreshReminder();
        }
        else if (SideBarPostBack.Value != String.Empty)
        {
            Context.Items.Add("cboClient", cboClient.SelectedValue);
            Context.Items.Add("txtSearch", txtSearch.Text);
            Session.Add("SideBarPostBack", "1");
            // tranfer to search page
            Server.Transfer("default2.aspx");
        }
        if(Context.Items.Count > 1 && Session["SideBarPostBack"]!=null) 
        {
            if (Session["SideBarPostBack"].ToString() == "1")
            {
                cboClient.SelectedValue = Context.Items["cboClient"].ToString();
                txtSearch.Text = Context.Items["txtSearch"].ToString();
                __IsPostBack = true;
            }
            Session.Remove("SideBarPostBack");
        }
        
    }

    public void refreshReminder()
    {
        // load reminder count            
        Mics.countReminder(lblB_ReminderCount, "Billing");
        Mics.countReminder(lblP_ReminderCount, "Proposal");
    }
    
    protected void imgSearch_Click(object sender, ImageClickEventArgs e)
    {
        Server.Transfer("default2.aspx");
    }
</script>

<div id="sidebar" class="sidebar">
    <input type="hidden" id="SideBarPostBack" runat="server" />
	<h3>Ops Files</h3>
	<div class="block">
		<div><h5>Search</h5></div>
		<div>Client : <asp:DropDownList ID="cboClient" runat="server" style="width:160px;" /></div>
		<div>Project : <asp:TextBox ID="txtSearch" runat="server" /> <img src="images/find.gif" align="absmiddle" onclick="SideBarSearch();" style="cursor:pointer;" /></div>
		<div align="center"><a class="blue" href="saveProposal.aspx">Add New Proposal</a></div>
	</div>
	<div class="block">
		<div><h5>Reminders</h5></div>
		<div class="item"><a class="blue" href="listReminders.aspx">Billing Reminder <asp:Literal ID="lblB_ReminderCount" runat="server" /></a></div>
		<div class="item"><a class="blue" href="listReminders_P.aspx">Proposal Reminder <asp:Literal ID="lblP_ReminderCount" runat="server" /></a></div>
	</div>
	<div class="block">
		<div><h5>Reports</h5></div>
		<div class="item"><a class="blue" href="ops_Summary.aspx">Proposal &amp; Confirmed Projects</a></div>
		
		<div class="item"><a class="blue" href="historical_Projects.aspx">Historical Data</a></div>
		<div class="item"><a class="blue" href="archived_Proposals.aspx">Archived proposals</a></div>
	</div>
</div>